<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="css/index.css">
    <style>
       div{
           height: 100px;
           background-color: cornflowerblue;
       }

    </style>
</head>
<body>
    
   <div style='width: 100px;'></div>

</body>
</html>
<script>

  let divObj = document.getElementsByTagName('div')[0];

   //获得宽度
    let w= divObj.style.width;
    console.log(w);
     let h =  divObj.style.height;
     console.log('---'+h+'-----');

</script>
